package Survey;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;

public abstract class DisplayModule extends JPanel{

	SurveyParameters data;
	JPanel top, center;
	int index;
	
	public DisplayModule(SurveyParameters data, int index){
		super();
		
		this.data = data;
		this.index = index;
		
		setLayout(new BorderLayout());		
		top = new JPanel();
		top.setOpaque(true);
		top.setBackground(Color.white);
		top.setLayout(new BoxLayout(top, BoxLayout.Y_AXIS));
		JLabel question = new JLabel((data.multipart ? "      " : "#" + index + ": ") + data.question);
		
		top.add(question);
		if(data.picture != null){
			top.add(new JLabel(data.picture));
		}
		
		center = new JPanel();
		center.setLayout(new BoxLayout(center, BoxLayout.X_AXIS));
		center.setOpaque(true);
		center.setBackground(Color.white);
		
		JPanel filler = new JPanel();
		filler.setOpaque(true);
		filler.setBackground(Color.white);
		filler.setMinimumSize(new Dimension(50, 1));
		filler.setPreferredSize(filler.getMinimumSize());
		
		add(top, BorderLayout.NORTH);
		add(center, BorderLayout.CENTER);
		add(filler, BorderLayout.WEST);
	}
	
	public abstract String[] getData();
	
}
